﻿@using zichan.Entity;
@{
    List<Menu> menus = zichan.Common.PowerHelp.GetUserMenu();

    string controller = ViewContext.RouteData.Values["Controller"].ToString().ToLower();
    string action = ViewContext.RouteData.Values["Action"].ToString().ToLower();

    Menu m1 = null, m2 = null;
    
    Menu menu = menus.FirstOrDefault(o => o.Controller == controller && o.Action == action);

    if (menu != null) { 
        List<int>  ids= menu.Path.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(o=>Convert.ToInt32(o)).ToList();

       var ms=  menus.Where(o => ids.Contains(o.Id)).OrderBy(o=>o.Id).ToList();
       m1 = ms.FirstOrDefault(o=>o.Id==ids[0]);
 
      if (ids.Count() > 1) {
          m2 = ms.FirstOrDefault(o => o.Id == ids[1]);
      }
    }
}

<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <i class="fa fa-home"></i>
            <a href="/">Home</a>
            <i class="fa fa-angle-right"></i>
        </li>

        @if(m1 != null){
        <li>
            <a href="@Url.Action(m1.Action,m1.Controller)">@m1.Title</a>
            <i class="fa fa-angle-right"></i>
        </li>
        }

        @if(m2 != null){
        <li>
            <a href="#">@m2.Title</a>
        </li>
        }
    </ul>
</div>